package org.jeecg.modules.system.controller;

import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.system.entity.bo.ChunkUploadBo;
import org.jeecg.modules.system.entity.bo.FileSliceConfBo;
import org.jeecg.modules.system.service.IFileUploadService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author xy
 * @description 分片上传实现类
 * @date 2024-04-21
 **/
@RestController
@RequestMapping("/sys/fileUpload")
@Slf4j
public class FileUploadController {

    @Resource
    private IFileUploadService fileUploadService;

    /**
     * 注册文件上传信息
     * @param bo
     * @return
     */
    @PostMapping("/chunk/register")
    public Result<?> registerFileSliceInfo(FileSliceConfBo bo) {
        return fileUploadService.registerFileSliceInfo(bo);
    }

    /**
     * 文件分片上传
     * @param bo
     * @return
     */
    @PostMapping("/chunk/upload")
    public Result<?> uploadChunk(@Valid ChunkUploadBo bo) {
        return fileUploadService.uploadChunk(bo);
    }

    /**
     * 文件分片合并
     * @param bo
     * @return
     */
    @PostMapping("/chunk/merge")
    public Result<?> mergeFile(FileSliceConfBo bo) {
        return fileUploadService.mergeFile(bo);
    }

    /**
     * 文件分片信息删除
     * @param bo
     * @return
     */
    @PostMapping("/chunk/delete")
    public Result<?> deleteFileInfo(FileSliceConfBo bo) {
        return fileUploadService.deleteFileInfo(bo);
    }
}
